<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Linkslistsservicesusers extends Model
{
    protected $table = 'links_lists_services_users';
    protected $primaryKey = 'id';

    public static function getLinksListsUsersSimple($openid)
    {
        return self::where("openid",$openid)->orderBy("time","DESC")->first();
    }

    public static function getLinksListsUsers($users_id,$openid,$links_id)
    {
        return self::select("id")->where("users_id",$users_id)->where("openid",$openid)->where("links_id",$links_id)->first();
    }

    public static function insertLinksListsUsers($users_id,$openid,$links_id)
    {
        return self::insert(["users_id"=>$users_id,"openid"=>$openid,"links_id"=>$links_id,"time"=>time(),"created_at"=>time()]);
    }

    public static function updateLinksListsTime($id)
    {
        return self::where("id",$id)->update(["time"=>time()]);
    }
}
